// pages/result/result.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
			items:[],
			img:'/icon/相机.png',
			currentImage:'/icon/收藏.png',
			saved:'/icon/收藏-选中.png',
			notSaved:'/icon/收藏.png',
			time:'2024-7-25',
			isSaved:false
		},
		saveThis: function(event) {
		let isSaved = this.data.isSaved
    let newImage = this.data.currentImage
		if (isSaved==false) {
			newImage=this.data.saved
			this.setData({
      currentImage: newImage,
			isSaved:true
    });
		console.log("Image clicked", event+'1');
		}	else{
			newImage=this.data.notSaved
			this.setData({
      currentImage: newImage,
			isSaved:false
    });
		console.log("Image clicked", event+'2');
		}
		const takingPhoto = wx.getStorageSync('takingPhoto');
wx.request({
      url: 'http://localhost:8001/record/saveRecord',//连接服务器
      method: 'POST',
      data: {
        isSaved: isSaved,
				manipulatePicture:takingPhoto,
				species:items.Name,
				counts:items.count,
				finishTime:time
      },
      success: function(res) {
        console.log('保存成功');
      },
      fail: function(err) {
        console.error('保存失败', err);
      }
    });
  },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})